//
//  NYSubjectAnalysisViewController.m
//  NiuWaJiaoYu
//
//  Created by MinLison on 2018/1/5.
//  Copyright © 2018年 niuwaketang. All rights reserved.
//

#import "NYSubjectAnalysisViewController.h"

@interface NYSubjectAnalysisViewController ()

@end

@implementation NYSubjectAnalysisViewController

- (void)viewDidLoad
{
        [super viewDidLoad];
        [self loadData];
}
- (void)configNavigationBar:(BaseNavigationBar *)navigationBar
{
        [super configNavigationBar:navigationBar];
        self.title = @"查看解析";
}
- (void)loadData
{
        [self setLoading:YES animation:YES];
        
        [[NYSubjectAnalysisRequest requestWithType:(self.type) param:@{
                                                                       [self getParamKey] : NOT_NULL_STRING_DEFAULT_EMPTY(self.type_id)
                                                                       }] startWithSuccess:^(__kindof BaseRequest * _Nonnull request, __kindof NSString *  _Nonnull data) {
                self.controllerView.htmlString = data;
                [self setSuccess];
        } failed:^(__kindof BaseRequest * _Nonnull request, NSError * _Nonnull error) {
                [self setError:error];
        }];
}
- (NSString *)getParamKey
{
        switch (self.type) {
                case NYSubjectAnalysisTypeGoodSubject:
                        return @"good_question_id";
                        break;
                case NYSubjectAnalysisTypeWrongSubject:
                        return @"wrong_question_id";
                        break;
                case NYSubjectAnalysisTypeExamine:
                        return @"examine_id";
                        break;
                case NYSubjectAnalysisTypeCutGame:
                        return @"examine_id";
                        break;
                case NYSubjectAnalysisTypeExercise:
                        return @"exercises_id";
                        break;
                case NYSubjectAnalysisTypeExaminationAnalysis:
                        return @"examination_subject_id";
                        break;
                default:
                        break;
        }
        return @"good_question_id";
}
+ (NYViewControllerNavigationBarType)navigationBarType
{
        return NYViewControllerNavigationBarTypeBlue;
}
+ (UIViewController<JLRRouteDefinitionTargetController> *)targetControllerWithParams:(NSDictionary *)parameters
{
        NYSubjectAnalysisType type = [parameters jk_integerForKey:kRequestKeyType];
        NSString *type_id = [parameters jk_stringForKey:kRequestKeyTypeID];
        if (type < 0 || type >= NYSubjectAnalysisTypeMax || NULLString(type_id)) {
                return nil;
        }
        NYSubjectAnalysisViewController *vc = [[NYSubjectAnalysisViewController alloc] init];
        vc.type_id = type_id;
        vc.type = type;
        return vc;
}
@end
